import Mock from 'mockjs'
import { param2Obj } from '@/utils';

const List = []
const count = 100

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment',
    title: '@ctitle(10, 20)',
    author: '@cname',
    importance: '@integer(1, 3)',
    'jd|0-100': 2,
    start_time: '@datetime',
    end_time: '@datetime'
  }))
}

export default {
  // getList: () => List,
  getList: config => {
    const { page, limit } = param2Obj(config.url);
    console.log(config.url)
    let mockList = List.filter(item => {
      return true;
    });

    const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));
    console.log(pageList)
    return {
      total: mockList.length,
      items: pageList
    }
  }
}
